//
//  OADininglistMangerVC.m
//  OA项目
//
//  Created by innofive on 2018/4/17.
//  Copyright © 2018年 inno. All rights reserved.
//

#import "OADininglistMangerVC.h"
#import "MCSwitchTabControl.h"
#import "MainTabBarViewController.h"
#import "OAApprovelistCell.h"




@interface OADininglistVC()

@end

@implementation OADininglistVC

- (void)viewDidLoad {
    [super viewDidLoad];

}
@end

@interface OADininglist1VC()

@end

@implementation OADininglist1VC

- (void)viewDidLoad {
    [super viewDidLoad];
    
}
@end

@interface OADininglist2VC()

@end
@implementation OADininglist2VC

- (void)viewDidLoad {
    [super viewDidLoad];
    
}
@end



@interface OADininglistMangerVC ()<panGestureRecognizerDelegate>
@property(nonatomic,strong)MainTabBarViewController *tabBarC;
@property(nonatomic,strong)MCSwitchTabControl *tabControl;
@end

@implementation OADininglistMangerVC

- (void)viewDidLoad {
    [super viewDidLoad];
    
    OADininglistVC  *vc  = [[OADininglistVC alloc]initWithStyle:(UITableViewStyleGrouped)];
    //    vc.view.backgroundColor = [UIColor yellowColor];
    
    OADininglist1VC *vc1 = [[OADininglist1VC alloc]initWithStyle:(UITableViewStyleGrouped)];
    //    vc1.view.backgroundColor = [UIColor redColor];
    
    OADininglist2VC *vc2 = [[OADininglist2VC alloc]initWithStyle:(UITableViewStyleGrouped)];
    
    NSArray *vcs = @[vc,vc1,vc2];
    MainTabBarViewController *tabBarC = [MainTabBarViewController new];
    tabBarC.panGestureDelegate = self;
    tabBarC.tabBar.hidden = YES;
    tabBarC.viewControllers = vcs;
    [self addChildViewController:tabBarC];
    [self.view addV:tabBarC.view];
    _tabBarC = tabBarC;
}

-(void)onLoadViewByWillAppear:(UIView *)view
{
    MCSwitchTabControl *v = [MCSwitchTabControl new];
    [v addTarget:self action:@selector(onClickChangeBtn:) forControlEvents:UIControlEventValueChanged];
    [v insertSegmentWithTitle:@"待审核" image:nil];
    [v insertSegmentWithTitle:@"已审批" image:nil];
    [v insertSegmentWithTitle:@"全部" image:nil];
    [view addV:v];
    _tabControl = v;
    WSELF(weakSelf);
    [self onMainQueueAddSub:^(UIView *view, CGPoint origin, CGSize size, CGPoint center) {
        v.frame = CGRectMake(0, 0, size.width,kFitH(45));
        weakSelf.tabBarC.view.frame = CGRectMake(0,kFitH(45),size.width,size.height-kFitH(45));
    }];
}

-(void)onClickChangeBtn:(MCSwitchTabControl *)button
{
    self.tabBarC.selectedIndex = button.selectedSegmentIndex;
    [button segmentLineScrollToIndex:button.selectedSegmentIndex animate:YES];
}

-(void)tabBarViewController:(MainTabBarViewController *)tabBarViewController SelectedIndex:(NSInteger)selectedIndex
{
    _tabControl.selectedSegmentIndex =selectedIndex;
    [_tabControl segmentLineScrollToIndex:selectedIndex animate:YES];
}

@end
